/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package services;

import java.io.IOException;
import java.io.InputStream;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 *
 * @author ambaye
 */
public class ConnexionBD {
    public static SqlSession session;
    public static String monFichierXml = "myBatis/myBatis.xml";

    public static SqlSession getConnexion() {
        SqlSessionFactory sqlFactory = null;

        InputStream inputStream;
        try {
           inputStream = Resources.getResourceAsStream(monFichierXml);
            sqlFactory = new SqlSessionFactoryBuilder().build(inputStream);

        } catch (IOException ex) {
           
        }
        return session = sqlFactory.openSession();
    }

    
    public static void closeConnexion(){
        session.close();    
    }
    
}
